/**
 * @file GlobalErrorDefs.h
 * @brief Defines global error codes for the application.
 *
 * -------------------------------------------------------------------------------------------------------------------------
 * REVISION HISTORY
 * -------------------------------------------------------------------------------------------------------------------------
 * | Version   | Date       | Author        | Ticket Id | Description                                           |
 * |-----------|------------|---------------|-----------|-------------------------------------------------------|
 * | 1.0       | 2024-09-25 | zhiyu5.liu  | N/A       | Initial definition as GlobalErrorDefs.h.                |
 * -------------------------------------------------------------------------------------------------------------------------
 * COPYRIGHT
 * -------------------------------------------------------------------------------------------------------------------------                                                                
 * \verbatim
 * Copyright (c) 2024-2025 by <company name>. All rights reserved.
 * \endverbatim 
 */
#ifndef COMMON_ERROR_DEFS_H
#define COMMON_ERROR_DEFS_H

namespace errors{


/**
 * @enum ErrorCode
 * @brief Defines specific error codes 
 */
enum class ErrorCode {
    Success = 0,                      ///< Operation completed successfully. No error.
    
    // User-provided IPC and related error codes (1001-1032)
    InitFailed = 1001,                ///< Initialization of an IPC component (e.g., socket, context, channel) failed.
    CloseFailed = 1002,               ///< Closing or cleaning up an IPC component failed.
    SendFailed = 1003,                ///< An attempt to send data failed.
    ReceiveFailed = 1004,             ///< A blocking receive operation failed (e.g., connection closed, error).
    ReceiveNonBlockingFailed = 1005,  ///< A non-blocking receive operation failed (excluding timeout or no data available, indicates an actual error state).
    ReceiveTimeoutFailed = 1006,      ///< A receive operation with a timeout failed specifically due to the timeout expiring.
    PublishFailed = 1007,             ///< Publishing a message in a Pub/Sub pattern failed.
    SubscribeFailed = 1008,           ///< Subscribing to a topic in a Pub/Sub pattern failed.
    RequestFailed = 1009,             ///< Sending a request in a Req/Rep or RPC pattern failed.
    RespondFailed = 1010,             ///< Sending a response in a Req/Rep or RPC pattern failed.
    CallRPCFailed = 1011,             ///< Executing a remote procedure call failed (could be network, server error, etc.).
    SharedMemoryFailed = 1012,        ///< An operation involving shared memory (creation, mapping, access) failed.
    StopFailed = 1013,                ///< An attempt to stop a running service or component failed.
    Timeout = 1014,                   ///< A general timeout occurred during an operation not covered by ReceiveTimeoutFailed.
    InvalidArgument = 1015,           ///< An invalid argument was provided to an IPC function or method.
    SyncPrimitiveFailed = 1016,       ///< An operation on a synchronization primitive (e.g., mutex, semaphore, condition variable) used by the IPC layer failed.
    InvalidConfig = 1017,             ///< The provided configuration for an IPC component is invalid or incomplete.
    OperationFailed = 1018,           ///< A generic IPC operation failed for an unspecified reason.
    UnsubscribeFailed = 1019,         ///< Unsubscribing from a specific topic failed.
    UnsubscribeVariantFailed = 1020,  ///< Unsubscribing using a TopicVariant failed (e.g., invalid variant state).
    InvalidOperation = 1021,          ///< The requested operation is not permitted in the current state of the IPC component (e.g., sending on a closed socket).
    ProtocolError = 1022,             ///< An error occurred related to the underlying communication protocol (e.g., malformed message).
    ThreadError = 1023,               ///< An error related to thread creation, management, or synchronization within the IPC library occurred.
    ContextTerminated = 1024,         ///< The underlying communication context (e.g., ZeroMQ context) has been terminated, making further operations invalid.
    CallbackError = 1025,             ///< An exception or error occurred within a user-provided callback function during message processing.
    PollError = 1026,                 ///< An error occurred while polling for I/O events (e.g., using select, poll, epoll).
    ResourceExhausted = 1027,         ///< A required system resource (e.g., memory, file descriptors, buffer space) is unavailable.
    InternalError = 1028,             ///< An unexpected internal error occurred within the IPC library logic.
    Interrupted = 1029,               ///< An operation was interrupted, possibly by a signal (e.g., EINTR).
    ConfigurationError = 1030,        ///< Error related to loading, parsing, or applying configuration settings.
    DataConversionError = 1031,       ///< Error during data serialization, deserialization, or type conversion needed for IPC.
    UnknownError = 1032,              ///< An error occurred, but the specific cause is unknown or not categorized.

    // New general error codes (starting from 1033)

    // Category: State and Lifecycle
    AlreadyInitialized = 1033,        ///< Component or system has already been initialized; cannot initialize again.
    NotInitialized = 1034,            ///< Component or system has not been initialized, but the current operation requires it to be.
    ShutdownInProgress = 1035,        ///< The system or component is currently in the process of shutting down; cannot perform the operation.
    NotSupported = 1036,              ///< The current component or system does not support the requested operation or feature.
    Cancelled = 1037,                 ///< Operation was cancelled before completion (e.g., by user or another process).
    InProgress = 1038,                ///< Operation is already in progress; cannot start or run concurrently.
    Deprecated = 1039,                ///< The feature, API, or operation is deprecated; should be avoided.
    NotImplemented = 1040,            ///< The feature, API, or operation is declared but not yet implemented.

    // Category: Parameters, Configuration, and Input
    MissingParameter = 1041,          ///< Missing required parameter, parameter variable, or configuration value.
    ValueOutOfRange = 1042,           ///< The provided numeric value is outside the acceptable or valid range.
    InvalidFormat = 1043,             ///< Data format does not match expectations, or parsing failed (e.g., malformed JSON, XML, or custom format).
    InvalidPath = 1044,               ///< Provided file or directory path is invalid, malformed, or inaccessible.
    InvalidInput = 1045,              ///< Generic error indicating invalid user input, not covered by other specific error codes.

    // Category: Resource Management (Supplement to ResourceExhausted)
    ResourceBusy = 1046,              ///< The requested resource is currently busy, locked, or in use by another process.
    ResourceNotAvailable = 1047,      ///< The requested resource could not be found, is inaccessible, or unavailable for other reasons (e.g., specific hardware device).
    OutOfMemory = 1048,               ///< Memory allocation attempt failed due to insufficient memory.
    BufferTooSmall = 1049,            ///< The provided buffer is too small to hold the data that needs to be written.

    // Category: File System Operations
    FileNotFound = 1050,              ///< The specified file or directory was not found at the given path.
    FileExists = 1051,                ///< Attempted to create a file or directory that already exists, and overwriting is not allowed.
    FileReadError = 1052,             ///< An error occurred while attempting to read from a file.
    FileWriteError = 1053,            ///< An error occurred while attempting to write to a file.
    DiskFull = 1054,                  ///< There is not enough space on the storage device to complete the write operation.
    IOError = 1055,                   ///< A general input/output error occurred, not covered by a more specific file error.
    DirectoryNotEmpty = 1056,         ///< Attempted to delete a non-empty directory.

    // Category: Permissions and Security
    AccessDenied = 1057,              ///< Permission to access the resource or perform the operation was denied.
    AuthenticationFailed = 1058,      ///< Authentication (e.g., login, credential verification) failed.
    AuthorizationFailed = 1059,       ///< Authorization failed; the authenticated user does not have sufficient permissions to perform the operation.
    SecurityError = 1060,             ///< A general security-related error occurred (e.g., SSL/TLS handshake failure, encryption error).

    // Category: Network Operations (Generic)
    ConnectionFailed = 1061,          ///< Could not establish a network connection to the target host or service.
    ConnectionClosed = 1062,          ///< The network connection was unexpectedly or prematurely closed.
    HostUnreachable = 1063,           ///< The target host is unreachable (e.g., no route to host, host down).
    NetworkDown = 1064,               ///< The local network interface or the network itself is down or unavailable.
    NameResolutionFailed = 1065,      ///< Could not resolve the hostname or service name to an IP address (e.g., DNS query failed).
    NetworkError = 1066,              ///< A general network error occurred.
    AddressInUse = 1067,              ///< The specified network address or port is already in use.

    // Category: Data Integrity and Validation
    DataCorrupted = 1068,             ///< The data being processed is corrupted, unreadable, or failed integrity checks.
    ChecksumMismatch = 1069,          ///< Data integrity check (e.g., checksum, CRC, hash) failed, indicating data corruption.
    EncodingError = 1070,             ///< An error related to character encoding or decoding (e.g., invalid UTF-8 sequence).
    DecryptionFailed = 1071,          ///< Failed to decrypt encrypted data.
    SerializationFailed = 1072,       ///< Failed to serialize the object or data structure.
    DeserializationFailed = 1073,     ///< Failed to deserialize the data back into an object or data structure.

    // Category: External Dependencies & Services
    ServiceUnavailable = 1074,        ///< The required external service, API, or remote endpoint is unavailable or unresponsive.
    DependencyFailed = 1075,          ///< The operation failed due to an error in a dependent component, library, or service.
    ThirdPartyError = 1076,           ///< The error originated from a third-party library, SDK, or component not under direct control.
    UpstreamError = 1077,             ///< An error received from an upstream service that this component depends on.

    // Category: Hardware
    DeviceError = 1078,               ///< A general error related to a hardware device failure or unresponsiveness.
    DeviceNotFound = 1079,            ///< The required hardware device was not found, is not connected, or is unavailable.

    // Category: System & Environment
    SystemTimeError = 1080,           ///< An error related to the system time, such as clock skew, invalid timestamps, or time synchronization issues.
    EnvironmentError = 1081,          ///< An error related to the system environment (e.g., missing environment variables, incompatible OS version).
    QuotaExceeded = 1082              ///< A user or system quota was exceeded (e.g., API rate limit, disk quota, message queue size).
};


} // namespace error_handler

#endif // COMMON_ERROR_DEFS_H
